﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Utils.WeChat.PayResult
{
    public class NotifyResult
    {
        public string id { get; set; }

        public string create_time { get; set; }

        public string resource_type { get; set; }

        public string event_type { get; set; }

        public string summary { get; set; }

        public ResourceResult resource { get; set; }

        public bool TransactionSuccess()
        {
            return "TRANSACTION.SUCCESS" == event_type;
        }

        public string Decrypt(string aesKey)
        {
            if (resource == null)
                throw Error.DefaultError("加密原");
            return Cryptography.AesGcmDecrypt(aesKey, resource.associated_data, resource.nonce, resource.ciphertext);
        }
    }
}
